<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
    	<base href="<%=basePath%>">
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="<%=basePath %>leyuiyc/css/font.css">
        <link rel="stylesheet" href="<%=basePath %>leyuiyc/css/xadmin.css">
        <link rel="stylesheet" href="<%=basePath %>layui/css/layui.css"  media="all">
        <script type="text/javascript" src="<%=basePath %>leyuiyc/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="<%=basePath %>leyuiyc/js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
	<div style="position: absolute;top: 10px;left: 400px;">
	<div class="layui-btn-container">
			<button type="button" class="layui-btn"
				lay-demotransferactive="getData">下一步</button>
			<button type="button" class="layui-btn"
				lay-demotransferactive="reload">全部重选</button>
		</div>
		<div id="test7" class="demo-transfer"></div>
	</div>
	<script src="<%=basePath %>layui/layui.js" charset="utf-8"></script>
		<script>
				layui.use(['form','slider','layedit', 'laydate', "jquery",'transfer', 'layer', 'util'], function(){
				  var form = layui.form
				  ,layedit = layui.layedit
				  ,laydate = layui.laydate
				  ,slider = layui.slider
				  ,transfer = layui.transfer
  				  ,layer = layui.layer
  				  ,util = layui.util
				  ,$ = layui.jquery;
				  
				 var dataGoods =  $.ajax({
    						url : "BaleGoods/selectCommonGoods.do",
    						method : "post",
    						dataType : "json",
    						async:false,
    						contentType:"application/json;charset=utf-8",
    						success : function(data) {
    							return data;
    						}
    						});
    				var dataG = dataGoods.responseJSON;
				  //实例调用
				  transfer.render({
				    elem: '#test7'
				    ,data: dataG
				    ,width:300
				    ,height:650
				    ,id: 'key123' //定义唯一索引
				    ,title: ['可打包商品', '打包商品']
				    ,showSearch: true
				  })
				  //批量办法
				  util.event('lay-demoTransferActive', {
				    getData: function(othis){
				      var getData = transfer.getData('key123'); //获取右侧数据
				      var array = JSON.stringify(getData);
				      
				      var storage = window.sessionStorage;
                    	  storage.setItem('array', array); 
                    	  layer.open({
	    					type : 2,
	    					title : '增加打包商品详情',
	    					maxmin : true,
	    					area : [ '1200px', '700px' ], //弹出框大小
	    					content : "BaleGoods/goBaleGoods-add.do",
	    					end : function() {}
	    					});
				    }
				    ,reload:function(){
				      //实例重载
				      transfer.reload('key123', {
				        title: ['可打包商品', '打包商品']
				        ,value: ['2', '5', '9']
				        ,showSearch: true
				      })
				    }
				    
				  });
				  //日期
				  laydate.render({
				    elem: '#newdate'
				    ,trigger: 'click'
				  });
				  //监听提交
				  form.on('submit(add)', function(data){
				  layer.alert(JSON.stringify(data.field))
				  console.log(JSON.stringify(data.field))
				  	$.ajax({
                    	url:"BaleGoods/addBaleGoods.do",
                    	method:"post",
                    	data:JSON.stringify(data.field),
                    	contentType:"application/json;charset=utf-8",
                    	dataType:"json",
                    	success:function(data){
                    		console.log(data)
                    		sessionStorage.setItem('BaleGoodsId',data);
                    		layer.msg('添加成功！', {icon: 6}); 
                    		
                    	}
                    	})
				    return false;
				  });
				  //自定义验证规则
				  form.verify({
				  goodsExchIntegral: [
				      /^\d+$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,createUserId: [
				      /^\d+$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]			
					,commonGoodsId: [
				      /^\d+$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]				  
				    ,baleAmount: [
				      /^\d+$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,shippingFee: [
				      /^[0-9]+(\.[0-9]{2})?$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,baleGoodPrice: [
				      /^[0-9]+(\.[0-9]{2})?$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,baleGoodsPrice: [
				      /^[0-9]+(\.[0-9]{2})?$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,returnFee: [
				      /^[0-9]+(\.[0-9]{2})?$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,awardedIntegral: [
				      /^\d+$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    ,balePresaleNum: [
				      /^\d+$/
				      ,'请输入正确格式的数字且不能带空格'
				    ]
				    
				    ,content: function(value){
				      layedit.sync(editIndex);
				    }
				  });
				  });
 			</script>

</body>

</html>
